package com.ocm.commerceinteraction.ui;


import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.Toast;

import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.ocm.commerceinteraction.GlobalApplication;
import com.ocm.commerceinteraction.model.BaseModel;
import com.ocm.commerceinteraction.util.XTHttp;

import org.apache.http.impl.client.DefaultHttpClient;

/**
 * A simple {@link Fragment} subclass.
 */
public abstract class BaseFragment extends Fragment {

    //    protected ObjectMapper objectMapper = new ObjectMapper();
    Gson gson = new Gson();

    abstract void initView();

    abstract void Click(View view);

    XTHttp xtHttp = new XTHttp();
    String param;

    protected String requestUrl = "";//访问地址
    protected String requestParams = "";//访问参数
    protected BaseModel baseModel;

    /**
     * 处理返回基本结构信息数据
     *
     * @param object 返回json结构
     */
    protected void dealBaseData(Object object) {
        try {
            baseModel = GlobalApplication.gson.fromJson(object.toString(), BaseModel.class);
        } catch (JsonSyntaxException e) {
            baseModel = GlobalApplication.gson.fromJson(object.toString(), BaseModel.class);
        }
        Toast.makeText(getActivity(), baseModel.getMsg(), Toast.LENGTH_SHORT).show();
    }

}
